import { defineStore } from 'pinia';
import { fetchLanguageOptions } from '@/service/api';

export const useLanguageStore = defineStore('language', {
    state: () => ({
        options: [] as Api.Language.LanguageOption[],
        loaded: false
    }),

    actions: {
        async loadOptions() {
            if (this.loaded) return;
            try {
                const res = await fetchLanguageOptions();
                this.options = res.data || [];
                this.loaded = true;
            } catch (error) {
                console.error('Failed to load language options:', error);
            }
        }
    }
}); 